package com.surfilter.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.surfilter.bean.GpsConfig;
import com.surfilter.dao.AnalysisMapper;

@Component
public class InitUtil implements CommandLineRunner{
  public static Map<String,GpsConfig> gpsMap = new HashMap<String, GpsConfig>();	
  @Autowired
  private AnalysisMapper analysisMapper;
  
  public void initGps() throws Exception {
	  List<GpsConfig> queryGpsRule = analysisMapper.queryGpsRule();
	  for(GpsConfig gpsConfig : queryGpsRule) {
		  Long id = gpsConfig.getId();
		  gpsMap.put(String.valueOf(id), gpsConfig);
	  }
  }

  @Override
  public void run(String... arg0) throws Exception {
	  initGps();
  }
}
